package o;

import android.graphics.Bitmap;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.resource.bitmap.Downsampler;
import com.bumptech.glide.load.resource.bitmap.Downsampler.e;
import java.io.IOException;
import java.io.InputStream;

public class xc implements se<InputStream, Bitmap> {
    private final Downsampler ˋ;
    private final ud ॱ;

    static class a implements e {
        private final aao ˋ;
        private final wz ˏ;

        a(wz wzVar, aao o_aao) {
            this.ˏ = wzVar;
            this.ˋ = o_aao;
        }

        public void ॱ() {
            this.ˏ.ˏ();
        }

        public void ˋ(uc ucVar, Bitmap bitmap) throws IOException {
            IOException ˊ = this.ˋ.ˊ();
            if (ˊ != null) {
                if (bitmap != null) {
                    ucVar.ˏ(bitmap);
                }
                throw ˊ;
            }
        }
    }

    public /* synthetic */ boolean ˊ(@NonNull Object obj, @NonNull sc scVar) throws IOException {
        return ˏ((InputStream) obj, scVar);
    }

    public /* synthetic */ tx ˎ(@NonNull Object obj, int i, int i2, @NonNull sc scVar) throws IOException {
        return ॱ((InputStream) obj, i, i2, scVar);
    }

    public xc(Downsampler downsampler, ud udVar) {
        this.ˋ = downsampler;
        this.ॱ = udVar;
    }

    public boolean ˏ(@NonNull InputStream inputStream, @NonNull sc scVar) {
        return this.ˋ.handles(inputStream);
    }

    public tx<Bitmap> ॱ(@NonNull InputStream inputStream, int i, int i2, @NonNull sc scVar) throws IOException {
        if (inputStream instanceof wz) {
            inputStream = (wz) inputStream;
            Object obj = null;
        } else {
            int i3 = 1;
            inputStream = new wz(inputStream, this.ॱ);
        }
        InputStream ˊ = aao.ˊ(inputStream);
        try {
            tx<Bitmap> decode = this.ˋ.decode(new aap(ˊ), i, i2, scVar, new a(inputStream, ˊ));
            return decode;
        } finally {
            ˊ.ˎ();
            if (obj != null) {
                inputStream.ॱ();
            }
        }
    }
}
